package cn.outsourcing.supermarket.controller;

import cn.outsourcing.supermarket.common.Result;
import cn.outsourcing.supermarket.dto.GoodsListSearchDTO;
import cn.outsourcing.supermarket.common.utils.ResultUtils;
import cn.outsourcing.supermarket.service.HiolabsGoodsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 前端控制器
 *
 * @author gzkemays
 * @since 2021-10-20
 */
@RestController
@RequestMapping("/goods")
public class HiolabsGoodsController {
  @Resource HiolabsGoodsService goodsService;

  @GetMapping("/list")
  public Result getGoodsList(GoodsListSearchDTO entity) {
    return ResultUtils.simpleResult(goodsService.getGoodsList(entity));
  }

  @GetMapping("/detail")
  public Result getGoodsDetail(@RequestParam(value = "id") Integer id) {
    return ResultUtils.simpleResult(goodsService.getGoodsDetails(id));
  }

  @GetMapping("/count")
  public Result getCount() {
    return ResultUtils.simpleResult(goodsService.getCount());
  }
}
